﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ConfigServices
{
    public class LayeredConfigReader : IConfigReader
    {
        private IEnumerable<IConfigService> _services;
        public LayeredConfigReader(IEnumerable<IConfigService> services)
        {
            _services = services;
        }
        public string GetConfig(string name)
        {
            string Value = null;
            foreach (var service in _services)
            {
                string newValue = service.GetConfig(name);
                if (!string.IsNullOrEmpty(newValue))
                {
                    Value = newValue;
                }
            }

            return Value;
        }
    }
}
